package com.vspush.udp.handle;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.socket.DatagramPacket;

import java.net.InetSocketAddress;

import com.vspush.cache.Cache;
import com.vspush.manage.LiveMessge;
import com.vspush.manage.MessageHeadle;
import com.vspush.udp.model.User;

public class LiveHeadle extends MessageHeadle{
	
	LiveMessge live = new LiveMessge();

	public LiveHeadle(String msg) {
		super(msg);
	}

	@Override
	public void headle(ChannelHandlerContext ctx,DatagramPacket msg) {
		InetSocketAddress masg = msg.sender();
		String name = this.msg;
		if(Cache.isHas(name)){
			User u=(User)Cache.get(name);
			u.setIsa(masg);
			live.online(masg,name);
		}else{
			live.offline(masg,name);
		}
	}

}
